﻿/// <summary>
/// https://leetcode-cn.com/problems/maximum-subarray/
/// </summary>
public class Solution
{
    public int MaxSubArray(int[] nums)
    {
        int sum = nums[0];
        int max = nums[0];
        foreach (var num in nums.Skip(1))
        {
            sum = Math.Max(num, sum + num);
            max = Math.Max(sum, max);
        }
        return max;
    }
}